<?php
namespace Model;
use SDF\Db\MongoCollection;
class notice extends MongoCollection
{
    /**
     * 供应商消息类
     */
    public function __construct()
    {
        parent::__construct('notice', 'supplier');
    }

    public  function add($describe,$create_name,$supplier_id,$order_id='',$receive,$sku_id='',$sign=""){
        $data['create_time'] = time();
        $data['describe'] = $describe;//描述；
        $data['create_name'] = $create_name;//创建者
        $data['supplier_id'] = $supplier_id;//订单id;
        $data['receive'] = $receive;//接收者
        if(!empty($order_id)){
            $data['order_id'] = $order_id;//订单id
        }
        if(!empty($sku_id)){
            $data['sku_id'] = $sku_id;
        }
        if(!empty($sign)){
            $data['sign'] = $sign;
        }
        $data['is_see'] = 0;//是否已读
        $res = $this->insert($data);
        if($res['ok']){
            return 1;
        }else{
            return 0;
        }

    }

    public function getComplete_time(){
        $notice_list = $this->find(array('create_name'=>'admin'));
        $notice_arr = array();
        foreach ($notice_list as $v){
            if(isset($v['order_id'])){
                $notice_arr[$v['supplier_id'.''].$v['order_id']] = $v['create_time'];
            }
        }
        return $notice_arr;

    }

}